<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" style="width: 100%;" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script>
		var currid = getID();
		var content = "";
		var AddDialog;
		var toolbartype = TOOLBAR_ADD + TOOLBAR_EDITOR;
		toolbartype += TOOLBAR_LOAD + TOOLBAR_REDO;
		content = AddToolBar(toolbartype);
		$("#toolbar").append(content);
		getDataGrid();
		var DialogWidth = 800;
		var DialogHeight = 370;

		function newdata() {
			var pLocation = "InternalGoodsAdd.html?id=-1";
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "气调库内部商品新增", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function editdata() {
			var row = $("#dg").datagrid("getSelected");
			if(!row) {
				$.messager.alert("消息", "请选中数据");
				return;
			}
			var pLocation = "InternalGoodsAdd.html?id=" + row.ID;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "气调库内部商品修改", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		//导出
		function loaddata() {
			if(currid === AddFlag) {
				$.messager.alert("警告", "该订单为新增订单，无法导出Excel！");
				return;
			}
			$.messager.confirm("提示", "确认导出Excel表格吗？", function(r) {
				if(r) {
					$.ajax({ //调用ajax方法，从服务器获取到该订单的所有数据
						type: "get",
						data: {
							"TYPE": '0'
						},
						url: RemoteLinkAddress + "/market/tenant/excel.do",
						dataType: "json", //服务器返回的数据类型
						success: function(result) {
							window.location.href = result.path;
						}, //请求成功后，接受服务器传来的Json字符串，并做相应的处理
						error: function(xhr, status, error) {
							$.messager.alert("错误", "请求失败!");
						}
					});
				}
			});
		}

		function redodata() {
			$('#dg').datagrid('options').url = RemoteLinkAddress + '/frozen/goods/list.do?';
			$('#dg').datagrid('reload');
		}

		function getDataGrid() {
			$('#dg').datagrid({
				url: RemoteLinkAddress + '/frozen/goods/list.do',
				toolbar: '#toolbar',
				method: 'get',
				pagination: 'true',
				rownumbers: 'true',
				fitColumns: 'true',
				singleSelect: 'true',
				height: 350,
				columns: [
					[{
						field: 'ID',
						title: 'ID',
						width: '0%'
					}, {
						field: 'NAME',
						title: '内部商品名称',
						width: '33%',
						align: 'center'
					}, {
						field: 'UNIT',
						title: '单位',
						width: '32%',
						align: 'center'
					}, {
						field: 'SPEC',
						title: '规格',
						width: '32%',
						align: 'center'
					}]
				],
				onDblClickRow: function(index, row) {
					var pLocation = "InternalGoodsAdd.html?id=" + row.ID;
					$("#ifrmEdit").attr("src", pLocation);
					constructDialog($("#dlg"), "气调库内部商品修改", DialogWidth, DialogHeight);
					AddDialog.dialog('open');
				}
			});
			$('#dg').datagrid('hideColumn', 'ID'); //隐藏第一列
		}

		function findmore() {
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('提示信息', '未选中数据!');
				return;
			}
			var pLocation = "UI/Market/BusinessInformation/BusinessInformation.html?id=" + row.ID;
			AddTabIn("固定商户相信息", parent.parent.$("#tabs"), pLocation);
		}

		function dialogClose() {
			AddDialog.dialog('close');
		}
	</script>

</html>